package com.gamemost.libepub;

import java.util.ArrayList;

public class TableOfContent {
	ArrayList<ItemRef> tableContent = new ArrayList<ItemRef>();
	public int getPos(String name) {
		System.out.println("indexx name "+name);
		for (int i = 0;i < tableContent.size();i++) {
			if (tableContent.get(i).getIdref().equals(name)) {
				return i;
			}
		}
		return 0;
	}
	public void addItem(ItemRef item) {
		tableContent.add(item);
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		String result = "";
		for (int i = 0;i < tableContent.size();i++) {
			result = result + tableContent.get(i) + "\n";
		}
		return result;
	}
	public ArrayList<ItemRef> getTableContent() {
		return tableContent;
	}
	public ItemRef getItemRef(int pos) {
		if (pos < tableContent.size() && pos >= 0) {			
			return tableContent.get(pos);
		}
		return null;
	}
	public int size() {
		return tableContent.size();
	}
}
